<link rel="stylesheet" href="${request.contextPath}/css/suredy-tree.css">
<div class="container-fluid suredy-form" style="padding-top: 0">
	<div class="row">	
	<form name="form" id="form">
	<#if org??>
	    <input type="hidden" name="id" id="id" value="${org.id}" />
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-addon">单位代码</div>
				<input type="text" class="form-control" id="code" name="code" value="${org.code}"  />
			</div>
		</div>
	
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-addon">单位名称</div>
				<input type="text" class="form-control" id="name" name="name" value="${org.name}" />
			</div>
		</div>	
		
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-addon">单位简称</div>
				<input type="text" class="form-control" id="alias" name="alias" value="${org.alias}" />
			</div>
		</div>					
		
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-addon">显示顺序</div>
				<input type="text" class="form-control" id="sort" name="sort" value="${org.sort}" />
			</div>
		</div>	
		
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-addon">单位描述</div>
				<textarea class="form-control" rows="3" id="description" name="description">${org.description}</textarea>
			</div>
		</div>	
		</#if>		
							
		<div class="text-center">
			<div class="btn btn-info" id="btn-save" >
				<i class="icon-save"></i> 保存
			</div>
		</div>	
	</form>	
	</div>
</div>
<script src="${request.contextPath}/js/suredy-tree.js"></script>
<script type="text/javascript">
	$(document).ready(function() {

		$('#btn-save').click(function() {
			var code = $('#code').val();
			var name = $('#name').val();
			
			if (code == '') {
				alert('请填写代码！');
				return;
			}

			if (name == '') {
				alert('请填写名称！');
				return;
			}
	
			$.ajax({
				url : 'ou/org/edit-save.do',
				dataType : 'json',
				type : 'POST',
				data : $('#form').serialize(),
				success : function(success) {
					if (!success) {
						alert('修改单位失败！');
					} else if (!success.success) {
						alert('修改单位失败！\n\n' + success.msg);
					} else {
						alert('修改单位成功！');
						$.suredy.loadContent('ou/manager.do');
						$.suredy.closeModal();
					}
				},
				error : function(a, b, c) {
					alert('服务器错误! ' + b);
				}
			});
		});	
	});
</script>	
